package aduros.net {

import flash.utils.Proxy;
import flash.utils.flash_proxy;

import com.whirled.net.MessageSubControl;

import aduros.util.F;

dynamic public class RemoteProxy extends Proxy
{
    public function RemoteProxy (ctrl :MessageSubControl, serviceName :String)
    {
        _caller = new RemoteCaller(ctrl, serviceName);
    }

    override flash_proxy function callProperty (name :*, ... args) :*
    {
        args.unshift(name);
        _caller.apply.apply(_caller, args);
    }

    override flash_proxy function getProperty (name :*) :*
    {
        return F.partial(flash_proxy::callProperty, name) as Function; // Cast to avoid warnings
    }

    protected var _caller :RemoteCaller;
}

}
